var express = require('express');
var router = express.Router();
var delivery = require('../controller/DeliveryController');

/* GET users listing. */
router.use('/:class/:func', function (req, res, next) {
// router.use('/index', function(req, res, next) {
    console.log('URI /' + req.params.class + '/' + req.params.func);
    req.session.proName = "delivery";

    try {
        switch (req.params.class) {
            case 'de' :
                delivery[req.params.func](req, res, next);
                break;
            default:
                res.render('delivery/error')
        }
    } catch (err) {
        console.error(err);
        res.render('delivery/error')
    }
});

module.exports = router;